package com.lagou.course.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lagou.course.CourseService;
import com.lagou.entity.Course;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("course")
public class CourseController {

    // 远程调用
    @Reference
    private CourseService  courseService;


    @GetMapping("/getAllCourse")
    public List<Course> getAllCourse(){
        List<Course> list = courseService.getAllCourse();
        return list;
    }

    @GetMapping("getCourseByUserId/{userid}")
    public List<Course> getCoursesByUserId(@PathVariable("userid") String userid ) {
        List<Course> list = courseService.getCourseByUserId(userid);
        return list;
    }

    @GetMapping("getCourseById/{courseid}")
    public Course getCourseById(@PathVariable("courseid") Integer courseid) {
        Course course = courseService.getCourseById(courseid);
        return course;
    }






}
